package com.xmy.cultivate.mapper;

import com.xmy.cultivate.entity.GradeCustomGrade;
import com.xmy.cultivate.entity.GradeCustomSet;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 班级自定义设置 Mapper 接口
 * </p>
 *
 * @author hpiggy
 * @since 2025-03-28
 */
public interface GradeCustomSetMapper extends BaseMapper<GradeCustomSet> {


    @Select({ "<script>",
            "SELECT GROUP_CONCAT(DISTINCT t1.`name`) as name " ,
            "FROM grade AS t1 " ,
            "INNER JOIN student_grade AS t2 ON t1.id = t2.grade_id AND t2.reading_status = 1 " +
            "WHERE t1.year_part = ${yearPart} " ,
            "AND t1.quarter_num = ${quarterNum} " ,
            "AND t1.subjects_id = #{subjectsId} " ,
            "AND t1.lesson_type = ${lessonType} " ,
            "AND t1.school_id = ${schoolId} " ,
            "AND t1.time_start = #{timeStart} " ,
            "AND t1.time_end = #{timeEnd} " ,
            "AND t1.week_dates IN (${weekDates}) " ,
            "AND t1.scheduling_type = #{schedulingType} " ,
            "AND t1.deleted = 0 ",
            "GROUP BY t1.id",
            "</script>"})
    public List<String> getStudentGradeName(
            @Param("yearPart") String yearPart,
            @Param("quarterNum") String quarterNum,
            @Param("lessonType") String lessonType,
            @Param("schoolId") String schoolId,
            @Param("subjectsId") String subjectsId,
            @Param("weekDates") String weekDates,
            @Param("timeStart") String timeStart,
            @Param("timeEnd") String timeEnd,
            @Param("schedulingType") String schedulingType);


}
